<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'basic';
$return=array();
/*******basic*******/
if($_RQ['op']=='basic'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		if(intval($postdata['groupdiscount'])<1 || $postdata['groupdiscount']>99){
			//exi('拼单折扣必须在1~100范围内','error');
		}
		$this->plugin_setting('basic',$postdata);
		exi('设置成功');
	}
	$item=$this->plugin_setting('basic');
	$bankuai =array(
		array('title'=>'新人专区','img'=>'../addons/jy_weishop/resource/mobile/images/icon/zhekou.png','action'=>'jy_psipingtuan/index/'),
		array('title'=>'趣味2人团','img'=>'../addons/jy_weishop/resource/mobile/images/icon/shishang.png','action'=>'jy_psipingtuan/index//teamnum=2'),
		array('title'=>'超值5人团','img'=>'../addons/jy_weishop/resource/mobile/images/icon/pinpai.png','action'=>'jy_psipingtuan/index//teamnum=5'),
		array('title'=>'秒团百人团','img'=>'../addons/jy_weishop/resource/mobile/images/icon/9.9.png','action'=>'jy_psipingtuan/index//teamnum=100'),
	);
	$footernav = array(
			array('title'=>'首页','icon'=>'icon-shouye','color'=>'#cc99ff','action'=>'jy_psipingtuan/index/','image'=>'../addons/jy_weishop/resource/images/jy_weishoparticle.png'),
			array('title'=>'我的预约','icon'=>'icon-success','color'=>'#66cc66','action'=>'jy_psipingtuan/yuyue/','image'=>'../addons/jy_weishop/resource/images/jy_fenleimsg.png'),
			array('title'=>'我的拼单','icon'=>'icon-yonghujieru','color'=>'#66cc66','action'=>'jy_psipingtuan/myteam/','image'=>'../addons/jy_weishop/resource/images/jy_fenleimsg.png'),
			array('title'=>'我的','icon'=>'icon-wo1','color'=>'#FF83FA','action'=>'jy_psipingtuan/myhome/','image'=>'../addons/jy_weishop/resource/images/jy_fenleimsg.png'),
	);
	$hdps =array(
		array('title'=>'1','picurl'=>'../addons/jy_psipingtuan/resource/images/hdp01.jpg'),
		array('title'=>'2','picurl'=>'../addons/jy_psipingtuan/resource/images/hdp02.jpg'),
	);
	$my_days = array(
				array('title'=>'我的优惠券','icon'=>'icon-youhuiquan','color'=>'#cc99ff','action'=>'jy_weishop/coupon.myindex/'),
				array('title'=>'微信会员卡','icon'=>'icon-daifahuo','color'=>'#cc99ff','action'=>'core/member.wxcard/main/'),
				//array('title'=>'余额提现','icon'=>'icon-dixiaofei','color'=>'#cc99ff','action'=>'core/member.tixian/'),
				array('title'=>'地址管理','icon'=>'icon-position','color'=>'#cc99ff','action'=>'core/member.address/'),
				array('title'=>'帮助中心','icon'=>'icon-help','color'=>'#cc99ff','action'=>'jy_weishop/news.list/'),
				//array('title'=>'获得购物卡','icon'=>'icon-qiangdan','color'=>'#cc99ff','action'=>'jy_weishop/member.getcard/'),
				array('title'=>'我的购物车','icon'=>'icon-gouwuche','color'=>'#cc99ff','action'=>'jy_weishop/member.cart/'),
				//array('title'=>'我的购物卡','icon'=>'icon-pingzhengzhongxin','color'=>'#cc99ff','action'=>'jy_weishop/member.mycard/'),
				//array('title'=>'我的关注','icon'=>'icon-woguanzhudepinpai','color'=>'#cc99ff','action'=>'jy_weishop/member.favorite/'),
				//array('title'=>'我的足迹','icon'=>'icon-zuji','color'=>'#cc99ff','action'=>'jy_weishop/member.history/'),
	);
	$item['my_days'] = !empty($item['my_days']) ? $item['my_days'] : $my_days;
	$item['demomy_days'] = $my_days;
	$my_logs = array(
				array('title'=>'积分日志','icon'=>'icon-jifen','color'=>'#cc99ff','action'=>'core/member.credit_log/'),
				array('title'=>'余额日志','icon'=>'icon-jiangjiatongzhi','color'=>'#cc99ff','action'=>'core/member.credit_log/'),
				array('title'=>'提现日志','icon'=>'icon-trade','color'=>'#cc99ff','action'=>'core/member.cash_log/'),
				array('title'=>'红包日志','icon'=>'icon-ai-hongbao','color'=>'#cc99ff','action'=>'core/member.red_log/'),
	);
	$item['my_logs'] = !empty($item['my_logs']) ? $item['my_logs'] : $my_logs;
	$item['demomy_logs'] = $my_logs;
	$my_memberbtn = array(
				array('title'=>'保证金日志','icon'=>'icon-jifen','color'=>'#cc99ff','action'=>'jy_psipingtuan/msglog//type=5'),
				array('title'=>'领取优惠券','icon'=>'icon-youhuiquan1','color'=>'#cc99ff','action'=>'jy_weishop/coupon.index/'),
				//array('title'=>'领取微信会员卡','icon'=>'icon-huiyuanqia','color'=>'#cc99ff','action'=>'core/member.wxcard/main'),
				array('title'=>'积分排行','icon'=>'icon-paixing','color'=>'#cc99ff','action'=>'core/member.rank/'),
	);
	$item['my_memberbtn'] = !empty($item['my_memberbtn']) ? $item['my_memberbtn'] : $my_memberbtn;
	$item['demomy_memberbtn'] = $my_memberbtn;
	$return['item']=$item;
	$return['item']['bao_type']=intval($return['item']['bao_type']);
	//只默认第一次；
	$return['item']['bankuai']=$return['item']['footernav']?$return['item']['bankuai']:$bankuai;
	$return['item']['footernav']=$return['item']['footernav']?$return['item']['footernav']:$footernav;
	$return['item']['hdps']=$return['item']['hdps']?$return['item']['hdps']:$hdps;
	$return['get_type']=$this->get_types;
	$planurl=custom_url('jy_psipingtuan/plan/',true);
	$htmls=array(
		'type'=>'edit',
		'desc'=>'参数设置',
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'基本信息',
				'list'=>array(
					array('type'=>'tip','title'=>'【务必】添加计划任务，否则自动拼团，预约等不正常（管理员可操作）！：</br>
					[两种设置计划任务的方法]：大家视情况二选一即可！</br>
					[注意]：<red>不能两种计划任务同时执行，否则会出现重复参团的情况；每次执行间隔时间不能低于10秒，建议30秒为优。</red></br>
					1、计划任务：系统--云服务--计划任务;任务URL：jy_psipingtuan/plan/</br>
					2、宝塔等面板直接添加(<red>推荐方法</red>)：任务URL：'.$planurl.'
					'),
					array('type'=>'string','title'=>'网站名称','name'=>'title'),
					array('type'=>'image','title'=>'网站logo','name'=>'logo'),
					array('type'=>'unitstring','unit'=>'次','title'=>'消费N次才能拼团','name'=>'need_buynum','help'=>'普通会员必须有N次消费体验才能够发起团购享受佣金。VIP会员可以直接发起团购享受佣金！'),
					array('type'=>'switch','title'=>'启用拼团权限','name'=>'is_check'),
					array('name'=>'showlevels','title'=>'会员等级拼团权限','type'=>'checkbox','options'=>'levels','show'=>array('is_check'=>1),'help'=>'不填则不限制，满足条件的会员，才可以进入本拼团！'),
					array('type'=>'unitstring','unit'=>'次','title'=>'或消费N次后','name'=>'buynum','show'=>array('is_check'=>1)),
					array('type'=>'switch','title'=>'关闭预约机制','name'=>'no_yuyue','help'=>'关闭后，不需要预约，需要自己手动拼团！'),
					array('type'=>'switch','title'=>'开启自动退款?','name'=>'is_zdrefund','help'=>'开启后，自动退款（原路返回），如果是微信支付的，就微信退款（除非：开启退款到保证金）'),
					array('type'=>'switch','title'=>'开启退款到保证金?','name'=>'is_tuibao','help'=>'开启后，退款到保证金！'),
					array('type'=>'switch','title'=>'关闭保证金提现','name'=>'no_baofeeti','help'=>''),
					array('type'=>'switch','title'=>'开启提现限制','name'=>'is_tixianfee','help'=>'开启后，提现总额不能超过充值总额'),
					array('type'=>'switch','title'=>'开启自动提现','name'=>'is_teamfee','help'=>'开启后，确认收货后立即到团长微信。不用团长发起提现申请!'),
					array('type'=>'image','title'=>'网站ICO','name'=>'icon'),
					array('type'=>'image','title'=>'首页横幅广告','name'=>'indexad','help'=>'高160，宽750'),
					array('type'=>'link','title'=>'首页横幅广告URL','name'=>'indexadurl','from'=>'action'),
					array('type'=>'string','title'=>'分享标题','name'=>'share_title'),
					array('type'=>'image','title'=>'分享图片','name'=>'share_image'),
					array('type'=>'string','title'=>'分享描述','name'=>'share_desc'),
				)
			),
			array(
					'title'=>'文字自定义',
					'list'=>array(
						array('type'=>'text','title'=>'商品描述1','name'=>'goodstitle1','help'=>'变量解析：{teamnum}是成团人数，{fannum}失败人数，{lastnum}拼中人数，{zhong_fee}是拼中奖励，{fan_fee}是失败奖励；默认例如：{teamnum}人拼团，{lastnum}人得商品+{zhong_fee}元'),
						array('type'=>'text','title'=>'商品描述2','name'=>'goodstitle2','help'=>'变量解析：{teamnum}是成团人数，{fannum}失败人数，{lastnum}拼中人数，{zhong_fee}是拼中奖励，{fan_fee}是失败奖励；默认例如：{fannum}人，每人奖励{fan_fee}红包补贴'),
						array('type'=>'text','title'=>'简单规则描述','name'=>'goodsdesc1','help'=>'（商品详情底部，下单页面底部显示）变量解析：{teamnum}是成团人数，{fannum}失败人数，{lastnum}拼中人数，{zhong_fee}是拼中奖励，{fan_fee}是失败奖励；默认例如：{teamnum}人成团,随机抽{lastnum}人拼中,没抽中的人获得{fan_fee}元奖励金！'),
					)
			),
			array(
					'title'=>'拼单规则',
					'list'=>array(
						array('type'=>'richtext','title'=>'拼单规则','name'=>'rules','help'=>''),
					)
			),
			array(
					'title'=>'机器人助手',
					'list'=>array(
						array('type'=>'image','title'=>'开通机器人顶部图','name'=>'vipbg'),
						array('type'=>'unitstring','unit'=>'元','title'=>'开通费用','name'=>'jiqi_fee'),
						array('type'=>'unitstring','unit'=>'分钟','title'=>'动开始前多久开始预约？','name'=>'jiqi_yuyuetime'),
						array('type'=>'switch','title'=>'是否开启分销','name'=>'jiqi_fenxiao'),
						array('type'=>'unitstring','unit'=>'%','title'=>'一级分销比例','name'=>'jiqi_fenxiaobi1'),
						array('type'=>'unitstring','unit'=>'%','title'=>'二级分销比例？','name'=>'jiqi_fenxiaobi2'),
						array('type'=>'switch','title'=>'是否开通购买年限','name'=>'jiqi_buynian','help'=>'不开通的话，就是永久使用；开启后，机器人只能按年购买。'),
					)
			),
			array(
					'title'=>'任务解锁',
					'list'=>array(
						array('type'=>'switch','title'=>'否开启任务解锁功能','name'=>'task_open'),
						array('type'=>'radio','title'=>'直推/间推(任务奖励类型)','name'=>'fen_futype','options'=>'credit_type','help'=>'选择余额，就表示正常结算，选择其他不能提现结算，成团后直接到账【具体的奖励金额，由会员等级/商品独立设置】，推荐奖励，优先按拼团商品独立设置的为准，如果商品没有独立设置，就按下面的默认！'),
						//array('type'=>'string_two','title'=>'推荐N人参与活动','title1'=>'推荐','unit1'=>'人','name1'=>'task_num1','title2'=>'推荐人（上级）','unit2'=>'元/币/佣金','name2'=>'task_fee1'),
						//array('type'=>'string_two','title'=>'推荐N人参与活动','title1'=>'推荐','unit1'=>'人','name1'=>'task_num2','title2'=>'拿1级','unit2'=>'元/币','name2'=>'task_fee2'),
						//array('type'=>'string_two','title'=>'再推荐N人参与活动','title1'=>'再推荐','unit1'=>'人','name1'=>'task_num3','title2'=>'拿2级','unit2'=>'元/币','name2'=>'task_fee3'),
						array('type'=>'unitstring','title'=>'福利解锁(推荐N人参与活动)','unit'=>'人','name'=>'task_funum'),
						array('type'=>'radio','title'=>'福利解锁(任务奖励类型)','name'=>'task_futype','options'=>'gift_type'),
						array('name'=>'task_fugoodsid','title'=>'选择奖励商品','type'=>'choose_title','action'=>'jy_weishop/goods.get_goods//noweike=1','show'=>array('task_futype'=>0)),
						array('type'=>'unitstring','title'=>'奖励金币','unit'=>'个','name'=>'task_funfee'),
					)
			),
			array(
					'title'=>'界面UI配色',
					'list'=>array(
						array('type'=>'color_pool','title'=>'选择配色方案','name'=>'syscolor','help'=>''),
						array('type'=>'colorpicker','title'=>'站点颜色','name'=>'syscolor','help'=>'自定义系统颜色系，默认： #18bc9c'),
						array('type'=>'phone_tpl','name'=>'syscolor'),
					)
			),
			array(
				'title'=>'幻灯片',
					'list'=>array(
						array(
							'type'=>'array',
							'name'=>'hdps',
							'add_tip'=>'添加一个幻灯片',
								'list'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'幻灯片图片'),
									array('type'=>'string','name'=>'url','title'=>'幻灯片链接'),
									
								),
								'details'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'幻灯片图片','help'=>''),
									array('type'=>'string','name'=>'url','title'=>'幻灯片链接'),
									
								)
						)
					)
			),
			array(
				'title'=>'板块导航',
					'list'=>array(
									array('type'=>'array','name'=>'bankuai','add_tip'=>'添加一个板块导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'image','name'=>'img','title'=>'导航图片'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'image','name'=>'img','title'=>'导航图片'),							
										array('type'=>'string','name'=>'action','title'=>'导航链接'),
									)
								),
					)
			),
			array(
				'title'=>'底部导航',
					'list'=>array(
								array('type'=>'switch','title'=>'强制显示本菜单','name'=>'is_myfooternav','help'=>'开启后，访问本插件的页面时，底部菜单不会跟随当前场景体的底部菜单！'),
								array('type'=>'array','name'=>'footernav','add_tip'=>'添加一个底部导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标','help'=>'图标，例如：icon-shouye'),							
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'导航链接'),
									)
								),
					)
			),
			array(
					'title'=>'会员中心页面开关设置',
					'list'=>array(
						array('type'=>'tip','title'=>'如需DIY会员中心页面：移步DIY装修--添加页面--页面类型--选择会员中心'),
						array('type'=>'switch','title'=>'关闭我的订单','name'=>'no_order'),
						array('type'=>'switch','title'=>'关闭待激活商品','name'=>'no_verify'),
						array('type'=>'switch','title'=>'关闭我的日常','name'=>'no_days'),
						array('type'=>'switch','title'=>'关闭售后客服','name'=>'no_shkefu'),
						array('type'=>'updemo','name'=>'my_days','demo'=>'demomy_days','title'=>'重置我的日常','help'=>'不知道添加什么我的日常？重置默认的一下试试！'),
						array('type'=>'array','title'=>'我的日常','name'=>'my_days','add_tip'=>'添加一个我的日常',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'日常名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'日常图标'),
										array('type'=>'string','name'=>'action','title'=>'日常链接'),
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'日常名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'日常图标'),
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'日常链接'),
									)
						),
						array('type'=>'switch','title'=>'关闭我的记录','name'=>'no_logs'),
						array('type'=>'updemo','name'=>'my_logs','demo'=>'demomy_logs','title'=>'重置我的记录','help'=>'不知道添加什么我的记录？重置默认的一下试试！'),
						array('type'=>'array','title'=>'我的记录','name'=>'my_logs','add_tip'=>'添加一个我的记录',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'记录名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'记录图标'),
										array('type'=>'string','name'=>'action','title'=>'记录链接'),
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'记录名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'记录图标'),
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'记录链接'),
									)
						),
						array('type'=>'tip','title'=>'其他导航列表'),
						array('type'=>'switch','title'=>'关闭其他导航','name'=>'no_others'),
						array('type'=>'updemo','name'=>'my_memberbtn','demo'=>'demomy_memberbtn','title'=>'重置导航','help'=>'不知道添加什么导航？重置默认的一下试试！'),
						array('type'=>'array','title'=>'其他导航','name'=>'my_memberbtn','add_tip'=>'添加一个导航按钮',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'导航链接'),
									)
						),
					)
				),
		),
	);
	$levels=pdo_getall('jy_weishop_member_level',array('uniacid'=>$_SESSION['uniacid'],'merchid'=>0),array('id','title'),'id');
	$return['levels']=array();
	$return['levels'][0]='默认会员';
	foreach($levels as $lv){
		$return['levels'][$lv['id']]=$lv['title'];
	}
	$return['gift_type']=$this->gift_type;
	$return['credit_type']=$this->credit_type;
	$return['htmls']=$htmls;
	exi($return);
}
/*******basic*******/
/*******op*******/
